#include<bits/stdc++.h>
using namespace std;

long long n,L,R;
long long ans;

int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>L>>R;
	ans=0;
	for(long long i=L;i<=R;i++){
		if(i%n>=ans)ans=(i%n);
	}
	cout<<ans<<endl;
	return 0;
}
